﻿@page "/friendlinks/list"
@inherits PageBase

<PageContainer>
    <Breadcrumb>
        <Breadcrumb>
            <BreadcrumbItem><Icon Type="home"></Icon></BreadcrumbItem>
            <BreadcrumbItem><Icon Type="link"></Icon><span>友链管理</span></BreadcrumbItem>
            <BreadcrumbItem><Icon Type="bars"></Icon><span>友链列表</span></BreadcrumbItem>
        </Breadcrumb>
    </Breadcrumb>
    <ChildContent>
        <Card>
            <Table TItem="GetAdminFriendLinkDto" DataSource="@links" Bordered=@true Size=@TableSize.Small>
                <Column @bind-Field="@context.Id" Title="Id" Sortable="false"></Column>
                <Column @bind-Field="@context.Name" Title="名称" Sortable="false"></Column>
                <Column @bind-Field="@context.Url" Title="链接" Sortable="false">
                    @context.Url
                </Column>
                <ActionColumn Title="操作">
                    <Space Size="@("small")">
                        <SpaceItem>
                            <Button Type="@ButtonType.Primary" OnClick="_ => Open(context)">编辑</Button>
                        </SpaceItem>
                        <SpaceItem>
                            <Popconfirm Title="确定删除吗?"
                                        Icon="close-circle"
                                        OnConfirm="(async () => await DeleteAsync(context.Id))">
                                <Button Danger>删除</Button>
                            </Popconfirm>
                        </SpaceItem>
                    </Space>
                </ActionColumn>
            </Table>
            <Drawer Closable="true"
                    Visible="@visible"
                    Placement="right"
                    Title='("编辑友链")'
                    Width="500"
                    OnClose="_ => Close()">
                <Form Model="@input"
                      LabelColSpan="4"
                      WrapperColSpan="16"
                      OnFinish="HandleSubmit">
                    <FormItem Label="名称">
                        <Input @bind-Value="@context.Name" />
                    </FormItem>
                    <FormItem Label="链接">
                        <Input @bind-Value="@context.Url" />
                    </FormItem>
                    <FormItem WrapperColOffset="4" WrapperColSpan="16">
                        <Button Type="@ButtonType.Primary" HtmlType="submit">保存</Button>
                    </FormItem>
                </Form>
            </Drawer>
        </Card>
    </ChildContent>
</PageContainer>